package sv.view;

import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
import sv.main.*;

public class MousePrebAdapter extends MouseAdapter {
	
	private MyNetwork connection;
	private JTextField textField;
	private JFrame frame;
	private Game game;
	private JTextArea log;
	
	public MousePrebAdapter(JTextField text, MyNetwork con, JFrame frame, Game oGame, JTextArea log){
		super();
		textField = text;
		connection = con;
		this.frame = frame;
		game = oGame;
		this.log = log;
		game = oGame;
	}
	
	public void mouseClicked(MouseEvent event){
		String host = textField.getText();
		JButton source = (JButton)event.getSource();
		if (source.getY() == 20){
			connection.startServer();
			game.setServer(true);
		}
		else {
			connection.connectTo(host);
			game.setServer(false);
		}
		frame.setVisible(false);
		new View(game, connection, log);
	}

}
